package com.car.postoffice;

import com.car.framework.IDataMapping;

public class TPostMark {
	private static int lastMarkId = 100;
	
	private String scheme;
	private int id;
	private IDataMapping mapping;
	
	protected TPostMark(String scheme, int id, IDataMapping mapping){
		this.scheme = scheme;
		this.id = id;
		this.mapping = mapping;
	}
	
	public String getScheme(){
		return this.scheme;
	}
	
	public final IDataMapping getMapping() {
		return mapping;
	}

	@Override
	public boolean equals(Object o){
		if(o == null ||
		   this.getClass() != o.getClass()){
			return false;
		}
		if(this == o){
			return true;
		}
		TPostMark oInstance = (TPostMark)o;
		return this.id == oInstance.id;
	}
	
	@Override
	public int hashCode(){
		return this.id;
	}
	
	public static TPostMark CreateId(String scheme, IDataMapping mapping){
		return new TPostMark(scheme, TPostMark.lastMarkId++, mapping);
	}
	
	@Override
	public String toString(){
		return "[" + this.scheme + "(" +
	              Integer.toString(this.id) +
	            ")]";
	}
}
